<template>
	<view @touchmove.stop.prevent="moveHandle">
		<uni-popup ref="popup" type="bottom" :safe-area='false' :mask-click="false">
			<view class="pop-box">
				<view class="pop-main-box">
					<view class="pop-main">
						<image class="pop-img" :show-menu-by-longpress="true" src="@/static/main-icon/chenggong.png"
							mode=""></image>
						<view class="pop-title">支付成功</view>
					</view>
				</view>
				<view class="footer-btn">
					<view class="back-btn" @click="timeupEvent">
						{{isRenew?'返回订单列表':'返回上一页'}}(<uni-countdown ref="timer" @timeup="timeupEvent" :showDay="false"
							color="#333" :fontSize='15' :showHour="false" :showMinute="false"
							:second="sec"></uni-countdown>s)
					</view>
					<view v-if="type !=='hide' && !isRenew" class="scan-btn" @click="toOrderPage">订单列表</view>
				</view>
			</view>

		</uni-popup>
	</view>
</template>

<script>
	export default {
		props: {
			type: {
				type: String,
				default: ''
			},
			isRenew: {
				type: Boolean,
				default: false
			},
			needRefresh: {
				type: Boolean,
				dafault: false
			}
		},
		data() {
			return {
				sec: 5
			}
		},
		methods: {
			// 禁止弹窗滚动
			moveHandle() {
				return false
			},
			// 打开弹窗
			openPop() {
				// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ，type 属性将失效 ，仅支持 ['top','left','bottom','right','center']
				this.$refs.timer.update()
				this.$refs.popup.open('center')
			},
			// 返回上一页
			timeupEvent() {
				if (this.isRenew) {
					this.toOrderPage()
				} else {
					if (this.needRefresh) {
						this.$emit('refreshBackPage')
					}
					uni.navigateBack()
				}
			},
			// 去我的订单
			toOrderPage() {
				uni.setStorageSync('freshPage', 'true')
				uni.switchTab({
					url: '/pages/myOrderPage/myOrderPage'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.pop-box {
		background-color: #FFFFFF;
		border-radius: 30rpx;
		box-sizing: border-box;

		.pop-main-box {
			width: 620rpx;
			height: 320rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.pop-main {
			.pop-img {
				width: 112rpx;
				height: 112rpx;
			}

			.pop-title {
				margin-top: 30rpx;
				font-weight: bold;
				font-size: 36rpx;
				color: #333333;
				text-align: center;
			}
		}

		.footer-btn {
			border-top: 1px solid #EEE;
			height: 100rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
		}

		.back-btn {
			flex: 1;
			display: flex;
			align-items: center;
			justify-content: center;
			border-right: 1px solid #EEE;
		}

		.scan-btn {
			flex: 1;
			display: flex;
			align-items: center;
			justify-content: center;
			color: #fcde02;
		}

	}
</style>